package src.lanqiao.true_question_E;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        long ans = 0;
        long pre = 0;
        int n = MyReader.nextInt();
        int []a = new int[n];
        int []b = new int[n];
        int []c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = MyReader.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = MyReader.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = MyReader.nextInt();
        }

        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);

        for(int i = 0; i < n; i++) {
            if(i > 0&& b[i] == b[i - 1]){
                ans += pre;
                continue;
            }

            int anums = 0;
            for (int j = 0; j < n; j++) {
                if(a[j] < b[i]) anums++;
                else break;
            }

            int bnums = 0;
            for (int j = n - 1; j >= 0; j--) {
                if(c[j] > b[i]) bnums++;
                else break;
            }

            pre = (long)anums * bnums;
            ans += pre;

        }
        System.out.println(ans);

    }
}

class MyReader{
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));//定义字符流
    static StringTokenizer tokenizer = new StringTokenizer("");
    static String nextLine() throws IOException {// 读取下一行字符串
        return reader.readLine();
    }
    static String next() throws IOException {// 读取下一个字符串
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {// 读取下一个int型数值
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {// 读取下一个double型数值
        return Double.parseDouble(next());
    }
}
